package work3;

import java.util.Scanner;

public class Quetion2 {
	public static void main(String[] args) {

		System.out.println("====== 系统菜单 ======");
		System.out.println("   1-- 文件");
		System.out.println("   2-- 编辑");
		System.out.println("   3-- 查看");
		System.out.println("   4-- 帮助");
		System.out.println("   0-- 退出");
		System.out.println("===================");
		System.out.println("请输入操作码（0-4）：");

		Scanner input = new Scanner(System.in);
		int num = input.nextInt();
		input.close();

		System.out.println("-------- 使用if...else --------");

		if (num == 1) {
			System.out.println("你选择了文件菜单");
		} else if (num == 2) {
			System.out.println("你选择了编辑菜单");
		} else if (num == 3) {
			System.out.println("你选择了查看菜单");
		} else if (num == 4) {
			System.out.println("你选择了帮助菜单");
		} else if (num == 0) {
			System.out.println("你选择了退出");
			System.exit(0);
		} else {
			System.out.println("你选择的操作码不正确！");
		}

		System.out.println("-------- 使用switch...case --------");
		switch (num) {
			case 1:
				System.out.println("你选择了文件菜单");
				break;
			case 2:
				System.out.println("你选择了编辑菜单");
				break;
			case 3:
				System.out.println("你选择了查看菜单");
				break;
			case 4:
				System.out.println("你选择了帮助菜单");
				break;
			case 0:
				System.out.println("你选择了退出");
				System.exit(0);
				break;
			default:
				System.out.println("你选择的操作码不正确！");
				break;
		}

	}
}
